package com.china.fragment;

import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.china.adapter.LoginListAdapter;
import com.china.base.BaseFragment;
import com.china.osourcechina.LoginActivity;
import com.china.vo.LoginList;
import com.china.osourcechina.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/5/7.
 */
public class Minefragment extends BaseFragment implements View.OnClickListener{

    //查询的选项
    private String[] name = new String[]{
            "消息", "博客", "便签", "团队"
    };
    //对应的图片
    private int[] image = new int[]{
            R.mipmap.icon_my_message, R.mipmap.icon_my_blog, R.mipmap.icon_my_note,
            R.mipmap.icon_my_team
    };
    private RelativeLayout login;
    private ImageView picture;
    private TextView uname;
    private ListView lv;

    private List<LoginList> list;

    @Override
    protected int getLoadViewId() {
        return R.layout.fragment_mine;
    }

    @Override
    protected void initView(View view) {
        //找寻控件
        login = (RelativeLayout) view.findViewById(R.id.mine_login);
        //登陆用户照片
        picture = (ImageView) view.findViewById(R.id.mine_picture);
        //用户的用户名
        uname = (TextView) view.findViewById(R.id.mine_uname);
        //用户的选项
        lv = (ListView) view.findViewById(R.id.mine_lv);
        //设置监听
        login.setOnClickListener(this);
        init();
    }

    private void init() {
        list = new ArrayList<LoginList>();
        LoginList loginList = null;
        for (int i = 0; i < image.length; i++) {
            loginList = new LoginList();
            loginList.setImage(image[i]);
            loginList.setUname(name[i]);
            list.add(loginList);
        }
        Log.i("login","列表展示---------------》"+list);
        lv.setAdapter(new LoginListAdapter(list,getActivity()));
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.mine_login:
                Intent intent = new Intent(getActivity(), LoginActivity.class);
                startActivity(intent);
                break;
        }
    }
}
